var p1={
    name:"zhangsan",
    age:20
};
//浅拷贝，p1与p2指向同一个对象，p1与p2完全独立，叫作深拷贝
//对象之间的赋值，默认是浅拷贝，深拷贝需要自己实现
var p2=p1;
var p3=deepCopy(p1);
console.log(p2);

//1.修改p2的值
p2.age=18;
//2.打印p2的值
console.log(p1);
//3.修改p1的值
p1.name="list";
//4.打印p2
console.log(p2);
//5.深拷贝
function deepCopy(obj){
    var o={};
    for(var key in obj){
        if(typeof obj[key]==='object'){
           o[key]=deepCopy(obj[key]);
        }else{
            o[key]=obj[key];
        }
    }
    return o;
}
console.log(p3);
//作业，使用递归实现对象扁平化处理
student={
    name:'zhangsan',
    address:{provice:'jiangsu',city:'nanjing',district:'big factory'},
    sex:'女'
}
studentPlat={
    name:'zhangsan',
    'address.provice':'jiangsu',
    'address.city':'nanjing',
    'address.district':'big factory',
    sex:'女'
}
var s1=student;
console.log(s1);
var s2=studentPlat;
console.log(s2);